package com.hopu.controller;

import com.hopu.entity.Result;
import com.hopu.entity.Video;
import com.hopu.entity.WorkCollectDTO;
import com.hopu.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/collection")
public class CollectController {

    @Autowired
    private CollectService collectService;

    /**
     * 收藏/取消收藏
     * @param workCollectDTO
     * @return
     */
    @PostMapping
    public Result toggleLike(@RequestBody WorkCollectDTO workCollectDTO) {
        collectService.toggleCollect(workCollectDTO);
        return Result.success();
    }

    /**
     * 获取收藏数量
     * @param video
     * @return
     */
    @PutMapping
    public Result updateCollection(@RequestBody Video video) {
        return Result.success(collectService.getCollectCount(video));
    }
}
